<?php
	class ConnectDb
	{
		private $host="localhost";
		private $database="sitenews";
		private $user="root";
		private $pass="root";
		public $conn=NULL;
		
		function __construct()
		{
			$this->conn=mysql_connect($this->host,$this->user,$this->pass);
			mysql_select_db($this->database,$this->conn) or die(mysql_error());
			mysql_query('set names "utf8"');
		}
		public function Cat($lang='vi',$AnHien=-1)
		{
			$query="SELECT idTL,TenTL 
					FROM theloai
					WHERE (lang='$lang' OR '$lang'='') AND (AnHien='$AnHien' OR '$AnHien'=-1)
					ORDER BY ThuTu";
			$result=mysql_query($query) or die(mysql_error());
			return $result;
		}
		public function subCat($lang='vi',$AnHien=-1)
		{
			$query="SELECT idLT,Ten
					FROM loai
					WHERE (lang='$lang' OR '$lang'=-1) AND (AnHien='$AnHien' OR '$AnHien'=-1)
					ORDER BY ThuTu";
			$result=mysql_query($query) or die(mysql_error());
		}
		public function subCatInCat($idTL,$AnHien=-1)
		{
			$query="SELECT idLT,Ten
					FROM loaitin
					WHERE (idTL='$idTL') AND (AnHien='$AnHien' OR '$AnHien'=-1)
					ORDER BY ThuTu";
			$result=mysql_query($query) or die(mysql_error());
			return $result;
		}
		
	}
?>